/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司                 </p>
 * <p>		    All right reserved. 		    </p>
 * <p>项目名称 ： 	 深圳公路信息资源整合及国省检日常化监管管理           </p>
 * <p>创建者   :	詹春贤 
 * <p>描   述  :   路网服务-应急演练  </p>
 * <p>最后修改 : $: 2017年8月29日-下午12:47:22 v 1.0.0	 Administrator   $ </p>
 * 
*/

package com.pengtu.gsj.entity.lwfw;

import java.util.Date;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.base.IdEntity;
import com.pengtu.gsj.utils.DateUtils;

@Entity 
@Table(name = "T_LWFW_EMERGDRILL")
public class EmergDrill extends IdEntity{

	/**
	 * serialVersionUID:TODO
	 *
	 * @since 1.0.0
	 */
	private static final long serialVersionUID = 8567134411725789523L;
	
	private String drillName; 				//演练名称
	private Date drillTime; 				//演练时间
	private String drillPlace; 				//演练地点
	private String drillType;				//演练类型
	private String drillOrg; 				//相关单位
	private String drillContent; 			//演练内容
	private String remark; 				   	   //备注
	private String year; 			      	   //年份
	
	private Integer bulletinNumber;		   //检测文件数
	private List<Attachment> attachments;	//加载附件
	
	
	public EmergDrill() {
	}
	
	@Column(name = "DRILLNAME")
	public String getDrillName() {
		return drillName;
	}

	public void setDrillName(String drillName) {
		this.drillName = drillName;
	}
	
	@Column(name = "DRILLTIME")
	public Date getDrillTime() {
		return drillTime;
	}

	public void setDrillTime(Date drillTime) {
		this.drillTime = drillTime;
	}
	
	@Column(name = "DRILLPLACE")
	public String getDrillPlace() {
		return drillPlace;
	}

	public void setDrillPlace(String drillPlace) {
		this.drillPlace = drillPlace;
	}


	@Column(name = "DRILLTYPE")
	public String getDrillType() {
		return drillType;
	}

	public void setDrillType(String drillType) {
		this.drillType = drillType;
	}


	@Column(name = "DRILLORG")
	public String getDrillOrg() {
		return drillOrg;
	}

	public void setDrillOrg(String drillOrg) {
		this.drillOrg = drillOrg;
	}


	@Column(name = "DRILLCONTENT")
	public String getDrillContent() {
		return drillContent;
	}

	public void setDrillContent(String drillContent) {
		this.drillContent = drillContent;
	}
	

	@Column(name = "YEAR")
	public String getYear() {
		return year;
	}

	/**
	 * setYear:
	 * 适用:从演练时间中获得年份，如果当前的时间为空，就获得系统当前时间的年份，防止报错
	 * @param year 
	 * @exception 
	 * @since  1.0.0
	*/
	public void setYear(String year) {
		if (null != drillTime) {
			this.year = DateUtils.convertDateToString(drillTime).substring(0, 4);
		} else {
			this.year = DateUtils.convertDateToString(DateUtils.getCurrentDate()).substring(0, 4);
		}
	}

	
	@Column(name = "REMARK")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	
	@Transient
	public Integer getBulletinNumber() {
		bulletinNumber = attachments.size();
		return bulletinNumber;
	}

	public void setBulletinNumber(Integer bulletinNumber) {
		this.bulletinNumber = bulletinNumber;
	}

	@OneToMany(fetch = FetchType.LAZY)
	@JoinColumn(name = "PARTID")
	public List<Attachment> getAttachments() {
		return attachments;
	}

	public void setAttachments(List<Attachment> attachments) {
		this.attachments = attachments;
	}
}
